package cn.wit.test;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;

import org.junit.Test;

public class Demo1 {
	@Test
	public void test() {
		
		String path = "D:\\暑期培训\\班长常见问题\\存在重复的元素utf-8.txt";
		String target ="D:\\暑期培训\\班长常见问题\\存在重复的元素gbk-8.txt";
		
		try(
				FileInputStream in = new FileInputStream(path);
				BufferedReader reader = new BufferedReader(new InputStreamReader(in,"utf-8"));
				
				FileOutputStream ou = new FileOutputStream(target); 
				BufferedWriter write =new BufferedWriter(new OutputStreamWriter(ou,"gbk"));
				
				
		) {
			
			String s = null;
			
			while((s=reader.readLine())!=null) {
				
				write.write(s);
				
			}
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
	}

}
